<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<!-- import CSS -->
	<link rel="stylesheet" href="/jeefast/mb/elementui-lib/lib/index.css">
	<link rel="stylesheet" href="/jeefast/mb/css/common.css">
	<title>化验单结果录入</title>
</head>
<body>
<div id="app" v-cloak>
	<div class="pd10 border-bottom ft-14">
		<a href="biochemicalManage.html">
			<el-button type="text" icon="el-icon-arrow-left">生化指标管理 - 识别结果</el-button>
		</a>
	</div>
	<div class="pd10">
		<div class="research-title">
			<span>{{this.projName}}</span><span>{{this.resName}}</span>
		</div>
		<div class="bioche-Data">
			<dl>
				<dt>患者编号：</dt>
				<dd>{{manage.id}}</dd>
			</dl>
			<dl>
				<dt>调研医生：</dt>
				<dd>{{manage.pat_name}}</dd>
			</dl>
			<dl>
				<dt>研究组：</dt>
				<dd>{{manage.res_name}}</dd>
			</dl>
			<dl>
				<dt>客观指标(生化指标)：</dt>
				<dd>
					<el-button type="primary" size="medium" @click="handleSave">保存数据</el-button>
					<el-button type="danger" size="medium" @click="handleRefuse">审核未通过</el-button>
					<el-button type="success" size="medium" @click="handleSuccess">审核通过</el-button>
				</dd>
			</dl>
		</div>
		<!-- 选项卡 -->
		<div class="el-tabs el-tabs--top el-tabs--border-card">
			<div class="el-tabs__header is-top">
				<div class="el-tabs__nav-wrap is-top">
					<div class="el-tabs__nav-scroll">
						<div class="el-tabs__nav is-top">
							<div v-for="(item,index) in stepArr" class="el-tabs__item is-top" :class="{active:activeIndex == index}" @click="handleClick(strpInfo[index].dataId,index)">{{item.name}}</div>
						</div>
					</div>
				</div>
			</div>
			<div class="el-tabs__content">
				<div class="bioche-cont">
					<div class="bc-left">
						<div v-for="(item,index) in stepImgArr">
							<img :src="ImgbaseUrl+item.url" alt="">
							<p>{{item.time}}</p>
						</div>
					</div>
					<div class="bc-right">
						<div class="search">
							<el-input type="text" placeholder="按名称查询" style="width:300px;" v-model="searchName"></el-input>
							<el-button type="primary" @click="search">查询</el-button>
						</div>
						<ul>
							<li>
								<span>名称</span>
								<span>结果值</span>
								<span>单位</span>
								<span>参考范围</span>
							</li>
							<li v-for="(item,index) in stepDataArr" v-if="stepShow == 1">
								<span>{{item.ddName}}</span>
								<span>
											<el-input type="text" v-model="item.results"></el-input>
										</span>
								<span>
											<el-input type="text" v-model="item.units"></el-input>
										</span>
								<span>
											<el-input type="text" v-model="item.ddReferenceValue"></el-input>
										</span>
							</li>
							<!-- 搜索显示 -->
							<li v-for="(item,index) in stepDataSearchArr" v-if="stepShow == 2">
								<span>{{item.ddName}}</span>
								<span>
											<el-input type="text" v-model="item.results"></el-input>
										</span>
								<span>
											<el-input type="text" v-model="item.units"></el-input>
										</span>
								<span>
											<el-input type="text" v-model="item.ddReferenceValue"></el-input>
										</span>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<!--  -->
	</div>
	<!-- 审核拒绝 -->
	<el-dialog title="审核拒绝" :visible.sync="dialogFormVisible">
		<el-form ref="form" :model="form" label-width="90px">
			<el-form-item label="拒绝原因:">
				<el-input type="textarea" :rows="3" v-model="form.reason" style="width:90%;"></el-input>
			</el-form-item>
		</el-form>
		<div slot="footer" class="dialog-footer">
			<el-button @click="dialogFormVisible = false">取 消</el-button>
			<el-button type="primary" @click="onSubmitRefuse">保 存</el-button>
		</div>
	</el-dialog>
</div>
</body>

<script src="/jeefast/mb/elementui-lib/lib/vue.js"></script>
<script src="/jeefast/mb/elementui-lib/lib/index.js"></script>
<script src="/jeefast/mb/js/jquery-1.9.1.min.js"></script>
<script src="/jeefast/mb/js/axios.js"></script>
<script src="/jeefast/mb/js/data.js"></script>
<script>
	var app = new Vue({
		el: "#app",
		mixins: [mix],
		data: function() {
			return {
				ImgbaseUrl:'http://medical.medcircle.cn/manbing/imgs/',
				activeIndex: 0,
				data_id: "",
				projName: "",
				resName: "",
				// 审核拒绝
				dialogFormVisible: false,
				form: {
					reason: ""
				},
				manage: {}, //生化指标管理（上半部分基础信息）
				stepArr: [],
				stepImgArr: [],  //图片
				stepDataArr:[],  //详情
				stepDataSearchArr:[],  //搜索数组接口
				// id
				strpInfo:[],
				searchName:"",
				stepShow:1,
				isEdit:""  //是否修改  1是  0否
			}
		},
		methods: {
			handleClick: function(id,index) {
				this.stepShow = 1
				this.searchName = ''
				this.activeIndex = index
				this.getResearchSetpDataDetail(id)
			},
			getResearchDataInfo: function(id) {
				let that = this;
				researchDataInfo({
					id: id
				}).then(res => {
					if (res.data.code == 0) {
					this.manage = res.data.data
					this.stepArr = res.data.step
					this.strpInfo= res.data.strpInfo
					this.getResearchSetpDataDetail(res.data.strpInfo[0].dataId)  // 化验单详情
				}
			})
			},
			//
			search: function() {
				this.stepDataSearchArr= []
				if(this.searchName == ""){
					this.stepDataSearchArr = this.stepDataArr
					this.stepShow = 1
				}else{
					this.stepShow=2
					for(let i =0;i<this.stepDataArr.length;i++){
						if(this.stepDataArr[i].ddName.indexOf(this.searchName) > -1){
							this.stepDataSearchArr.push(this.stepDataArr[i])
						}
					}
				}
			},
			// 审核拒绝
			handleRefuse: function() {
				this.dialogFormVisible = true
			},
			onSubmitRefuse: function() {
				let that = this
				if (this.form.reason == "") {
					this.$message.warning('拒绝原因不能为空')
					return
				}
				researchDataRefuse({
					id: this.data_id,
					reason: this.form.reason
				}).then(res => {
					if (res.data.code == 0) {
					that.$message.success('已拒绝')
					that.getResearchDataInfo(that.data_id);
					this.activeIndex = 0;

					// window.location.href = "biochemicalManage.html"
				}
			})
			},
			// 审核通过
			handleSuccess:function(){
				// console.log(this.data_id)
				let that = this
				researchDataAccept({
					id:this.data_id
				}).then(res=>{
					if(res.data.code==0){
					that.$message.success('审核通过')
					that.getResearchDataInfo(that.data_id);
					this.activeIndex = 0;
					// window.location.href = "biochemicalManage.html"
				}
			})
			},
			// 详情
			getResearchSetpDataDetail: function(id) {
				researchSetpDataDetail({
					dataId: id
				}).then(res => {
					if (res.data.code == 0) {
					this.stepImgArr=res.data.img
					this.stepDataArr = res.data.data
					for(let i =0;i<this.stepDataArr.length;i++){
						if(this.stepDataArr[i].ddValue!=null) {
							let ddValue = this.stepDataArr[i].ddValue.split('/')
							this.stepDataArr[i].results = ddValue[0]
							this.stepDataArr[i].units = ddValue[1]
						}
						if(this.stepDataArr[i].ddType == 1){
							this.stepDataArr[i].ddName = 'ALB'
						}else if(this.stepDataArr[i].ddType == 2){
							this.stepDataArr[i].ddName = 'CPR'
						}else if(this.stepDataArr[i].ddType == 3){
							this.stepDataArr[i].ddName = 'TCHO'
						}else if(this.stepDataArr[i].ddType == 4){
							this.stepDataArr[i].ddName = 'TG'
						}else if(this.stepDataArr[i].ddType == 5){
							this.stepDataArr[i].ddName = 'LDL-C'
						}else if(this.stepDataArr[i].ddType == 6){
							this.stepDataArr[i].ddName = 'HDL-C'
						}else if(this.stepDataArr[i].ddType == 7){
							this.stepDataArr[i].ddName = 'SCR'
						}else if(this.stepDataArr[i].ddType == 8){
							this.stepDataArr[i].ddName = 'BUN'
						}else if(this.stepDataArr[i].ddType == 9){
							this.stepDataArr[i].ddName = 'p'
						}
					}
				}
			})
			},
			// 保存数
			handleSave:function(){
				let that = this
				for(let i =0;i<this.stepDataArr.length;i++){
					var results=typeof(this.stepDataArr[i].results) == "undefined"?'':this.stepDataArr[i].results;
					var units=typeof(this.stepDataArr[i].units) == "undefined"?'':this.stepDataArr[i].units;
					this.stepDataArr[i].ddValue = results+'/'+units
				}
				let stepDataArr = JSON.stringify(this.stepDataArr)
				// console.log(stepDataArr)
				researchSetpDataUpdate(stepDataArr).then(res=>{
					if(res.data.code==0){
					that.$message.success('保存成功')
					that.getResearchDataInfo(that.data_id);
					this.activeIndex = 0;
				}else{
					that.$message.error(res.data.msg)
				}
			})
			}

		},
		created() {
			this.data_id = getQueryString("data_id");
			this.getResearchDataInfo(this.data_id);

			this.projName = localStorage.getItem('projName')
			this.resName = localStorage.getItem('resName')


			// this.isEdit = getQueryString("isEdit");

		},
	});
</script>
</html>
